<?php 
/*
# ------------------------------------------------------------------------
# JA Seleni for Joomla 1.5.x - Version 1.0 - Licence Owner JA115884
# ------------------------------------------------------------------------
# Copyright (C) 2004-2009 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
# @license - Copyrighted Commercial Software
# Author: J.O.O.M Solutions Co., Ltd
# Websites:  http://www.joomlart.com -  http://www.joomlancers.com
# This file may not be redistributed in whole or significant part.
# ------------------------------------------------------------------------
*/

/**
 * JA News Sticker module allows display of article's title from sections or categories. \
 * You can configure the setttings in the right pane. Mutiple options for animations are also added, choose any one.
 * If you are using this module on Teline III template, * then the default module position is "headlines".
 */
  // no direct access
defined('_JEXEC') or die('Restricted access');
/**
 * JElementSection class.
 */
class JElementSection extends JElement
{
	/*
	 * Section name
	 *
	 * @access	protected
	 * @var		string
	 */
	var	$_name = 'Section';
	function fetchElement($name, $value, &$node, $control_name)
	{
		$arrOpt = array();
		$options = $this->getSections();
		for($i=0; $i < count($options); $i++){		
			$arrOpt[$i]['keys'] = $options[$i]->id;
			$arrOpt[$i]['value'] = $options[$i]->title; 
		}		
		
		return JHTML::_('select.genericlist',  $arrOpt, ''.$control_name.'['.$name.'][]', 'class="inputbox" multiple=""', 'keys', 'value', $value, $control_name.$name );		
	}
	
	function getSections()
	{
		$db = JFactory::getDBO();
		$query = 'SELECT s.id, s.title' .
				' FROM #__sections AS s' .
				' ORDER BY s.ordering';
		$db->setQuery($query);

		$sections[] = JHTML::_('select.option', '-1', '- '.JText::_('Select Section').' -', 'id', 'title');
		$sections = array_merge($sections, $db->loadObjectList());
		
		return $sections;
	}
}

?>
